package com.smart.gateway.config;

import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.ValueOperations;

/**
 * 动态路由配置
 *
 * @author guxiaobai
 * @date 2018/12/11 11:55
 */
@Configuration
@AllArgsConstructor
public class DynamicRouteConfiguration {
    private final ZuulProperties zuulProperties;
    private final ServerProperties server;
    private final ValueOperations<String, String> valueOperations;


    @Bean
    public DynamicRouteLocator dynamicRouteLocator() {
        return new DynamicRouteLocator(
                server.getServlet().getPath()
                , zuulProperties
                , valueOperations);
    }
}
